package com.dwxt.sport.business.controller;

/**
 * TODO
 *
 * @author Kuang.JiaZhuo
 * @date 2020-07-30 14:50
 */

import com.dwxt.common.base.BaseResult;
import com.dwxt.sport.business.entity.DeformitySportsHealth;
import com.dwxt.sport.business.entity.DeformitySportsHealthEquipment;
import com.dwxt.sport.business.service.DeformitySportsHealthService;
import com.dwxt.sport.business.vo.deformitySportsHealth.InsertOrUpdateDeformityEquipmentVo;
import com.dwxt.sport.business.vo.deformitySportsHealth.InsertOrUpdateDeformitySportsHealthVo;
import com.dwxt.sport.business.vo.deformitySportsHealth.SelectDeformitySportsHealthVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 残疾人运动健康
 *
 * @author Kuang.JiaZhuo
 * @date 2020-07-30 10:15
 */
@RestController
@RequestMapping("/deformitySportsHealth")
@Api(tags={"残疾人运动健康"})
public class DeformitySportsHealthController {

    @Resource
    DeformitySportsHealthService deformitySportsHealthService;

    @ApiOperation(value = "新增或修改残疾人运动健康", notes = "新增或修改残疾人运动健康", response = Integer.class)
    @PostMapping("/back/insertOrUpdateDeformitySportsHealth")
    public BaseResult insertOrUpdateDeformitySportsHealth(InsertOrUpdateDeformitySportsHealthVo insertOrUpdateVo){
        int result = this.deformitySportsHealthService.insertOrUpdateDeformitySportsHealth(insertOrUpdateVo);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "获取残疾人运动健康列表", notes = "按条件查询残疾人运动健康列表(带分页)", response = DeformitySportsHealth.class)
    @PostMapping("/back/selectDeformitySportsHealthByCriteria")
    public BaseResult selectDeformitySportsHealthByCriteria(SelectDeformitySportsHealthVo selectVo){
        PageInfo<DeformitySportsHealth> pageInfo = this.deformitySportsHealthService.selectDeformitySportsHealthByCriteria(selectVo);
        return BaseResult.ok(pageInfo);
    }

    @ApiOperation(value = "删除残疾人运动健康", notes = "根据ids批量删除残疾人运动健康", response= Integer.class)
    @PostMapping(value = "/back/deletetDeformitySportsHealthByIds")
    public BaseResult deletetDeformitySportsHealthByIds(@ApiParam(value = "要删除的id字符串,以英文逗号隔开", required = true) @RequestParam String ids){
        int result = this.deformitySportsHealthService.deletetDeformitySportsHealthByIds(ids);
        return BaseResult.ok(result);
    }


    /******************************************************************  关联设备  ******************************************************************************/

    @ApiOperation(value = "新增 或 更新【残疾人运动健康】设备关联", notes = "新增 或 更新【残疾人运动健康】设备关联", response = Integer.class)
    @PostMapping("/back/insertOrUpdateRelationEquipment")
    public BaseResult insertOrUpdateRelationEquipment(InsertOrUpdateDeformityEquipmentVo insertOrUpdateVo){
        int result = this.deformitySportsHealthService.insertOrUpdateRelationEquipment(insertOrUpdateVo);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "删除【残疾人运动健康】设备关联", notes = "根据ids批量删除【残疾人运动健康】设备关联", response= Integer.class)
    @PostMapping(value = "/back/deleteRelationEquipmentByIds")
    public BaseResult deleteRelationEquipmentByIds(@ApiParam(value = "要删除的id字符串,以英文逗号隔开", required = true) @RequestParam String ids){
        int result = this.deformitySportsHealthService.deleteRelationEquipmentByIds(ids);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "查询【残疾人运动健康】的设备列表", notes = "根据【残疾人运动健康】的id查询关联设备的列表(带分页)", response= DeformitySportsHealthEquipment.class)
    @PostMapping(value = "/back/selectRelationEquipmentByCriteria")
    public BaseResult selectRelationEquipmentByCriteria(@ApiParam(value = "青少年运动健康关联id", required = true) @RequestParam String id,
                                            @ApiParam(value = "起始页", required = true) @RequestParam Integer pageNum,
                                            @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize){
        String healthId = id;
        PageInfo<DeformitySportsHealthEquipment> pageInfo = this.deformitySportsHealthService.selectRelationEquipmentByCriteria(pageNum,pageSize,healthId);
        return BaseResult.ok(pageInfo);
    }
}
